package mop.gui.project;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JOptionPane;
import mop.controller.ProjectController;
import mop.gui.main.MainWindow;

public class RemoveProjectAction implements MouseListener {
    
    private String description;
    
    public RemoveProjectAction(String description)
    {
        this.description = description;
    }

    public void mouseClicked(MouseEvent e)
    {
        int result = JOptionPane.showConfirmDialog(null, 
                "Are you sure you want to remove this project?", "Are you sure?", JOptionPane.YES_NO_OPTION);
        
        if ( result == JOptionPane.YES_OPTION ) {
            ProjectController.getInstance().removeProject(this.description);
            JOptionPane.showMessageDialog(null, "Project removed!", "Success", JOptionPane.INFORMATION_MESSAGE);
            MainWindow.getInstance().update();
        }
    }

    public void mousePressed(MouseEvent e)
    {
    }

    public void mouseReleased(MouseEvent e)
    {
    }

    public void mouseEntered(MouseEvent e)
    {        
    }

    public void mouseExited(MouseEvent e)
    {
    }

}